<?php
echo 'a = "unset" (string): '.is_good_param( $a,'string')."\n"; 
echo 'a = "unset"  (number): '.is_good_param( $a,'number')."\n"; 
echo 'a = "unset"  (bool): '.is_good_param( $a,'bool')."\n"; 
echo 'a = "unset"  (): '.is_good_param( $a,'')."\n\n"; 

$a = $b;
echo 'a = "unset" (string): '.is_good_param( $a,'string')."\n"; 
echo 'a = "unset"  (number): '.is_good_param( $a,'number')."\n"; 
echo 'a = "unset"  (bool): '.is_good_param( $a,'bool')."\n"; 
echo 'a = "unset"  (): '.is_good_param( $a,'')."\n\n"; 

$a = 'abra';
echo 'a = "abra" (string): '.is_good_param( $a,'string')."\n"; 
echo 'a = "abra"  (number): '.is_good_param( $a,'number')."\n"; 
echo 'a = "abra"  (bool): '.is_good_param( $a,'bool')."\n"; 
echo 'a = "abra"  (): '.is_good_param( $a,'')."\n\n"; 

$a = '0';
echo 'a = "0" (string): '.is_good_param( $a,'string')."\n"; 
echo 'a = "0"  (number): '.is_good_param( $a,'number')."\n"; 
echo 'a = "0"  (bool): '.is_good_param( $a,'bool')."\n"; 
echo 'a = "0"  (): '.is_good_param( $a,'')."\n\n"; 

$a = 'false';
echo 'a = "false" (string): '.is_good_param( $a,'string')."\n"; 
echo 'a = "false"  (number): '.is_good_param( $a,'number')."\n"; 
echo 'a = "false"  (bool): '.is_good_param( $a,'bool')."\n"; 
echo 'a = "false"  (): '.is_good_param( $a,'')."\n\n"; 


function is_good_param( $a, $ptype ) {
    if( !isset($a) || !is_string($a) ) return false;
    $b = strip_tags( $a );
    if( $a != $b ) return false;
    switch( $ptype ) {
        case 'string': $result = ( $a != '' ); break;
        case 'number': $result = is_numeric( $a ); break;
        case 'bool': $a = strtolower( $a ); $result = ( $a == 'false' || $a == 'true' ); break;
        default: $result = false;
    }
    
    return $result;
}
?>
